package dabs.engine.plant;

import dabs.engine.control.ComponentCommand;
import dabs.engine.messaging.NotificationHandler;

public class Turbine extends ComponentPart{
	private static final long serialVersionUID = 2706295775201946114L;
	
	private int powerGenerated = 0;
	
	public Turbine(NotificationHandler mailBox, String name, int capacity, int outRate) {
		super(mailBox, name, capacity, outRate);
	}
	
	public int getPowerGenerated() { return powerGenerated; }

	@Override
	public void tick() {
		int powerThisTick = getNewHydroState().getSteamLevel();
		getNewHydroState().sendToNext(getHydroProp().getOutRate(), false, getOutputs(), getPressure());
		powerThisTick -= getNewHydroState().getSteamLevel();
		powerGenerated += powerThisTick;
		super.tick();
	}
	
	@Override
	public void runCommand(ComponentCommand command) {
		// TODO Auto-generated method stub
	}
	
	@Override
	public String read() {
		return String.format("%s\tScore: %s\n", super.read(), getPowerGenerated());
	}

}
